﻿using Foundation.Core;
using Microsoft.Extensions.DependencyInjection;

namespace Foundation.EntityFrameworkCore
{
    public class EntityStateResetTrackerFactory : IEntityStateResetTrackerFactory, ITransientDependency
    {
        private readonly IServiceProvider _serviceProvider;

        public EntityStateResetTrackerFactory(IServiceProvider serviceProvider)
        {
            this._serviceProvider = serviceProvider;
        }


        public IEntityStateResetTracker Create(EntityResetTrackingOptions options)
        {
            var service = _serviceProvider.GetService<EntityStateResetOptionsTracker>();

            service.SetOptions(options);

            return service;
        }
    }
}
